$(function() {
	vueFunc();
})

// 用户选择
function selectSH(id) {
	var te = $("#SH").attr("btnType");
	if(te == "隐藏") {
		$("#SH").attr("btnType", "显示");
		$("#selectBox").fadeIn(600, function() {
			$("#selectBox").css("display", "block")
		})
	}
	if(te == "显示") {
		$("#SH").attr("btnType", "隐藏");
		$("#selectBox").fadeOut(600, function() {
			$("#selectBox").css("display", "none")
		})
	}
}
// 用户选择结束

//设置session参数
function setSessionfunc(typeid,zid){
	//设置当前用户的session值
    //typeid 系统分类id (比如对应前端八大类), zid 当前用户的站点id
	var url="/bigscrenn/setUserSession?typeid="+typeid+"&zid="+zid;
    $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
              console.log(data,'参数');         
	     }
    		
    });	
};

// 电力图或 视频 方法开始
function elc_video(id) {
	var elcId = $("#elcPicId").attr("id");// 电气图(运行状态监测)id
	var videoId = $("#videoId").attr("id");// 视频监控id
	var elc_huanJingId = $("#elc_huanJingId").attr("id");// 环境状态监测id
	var elc_anFangId = $("#elc_anFangId").attr("id");// 安防监控id
	$("#elc_video").html("");// 将视频置空，否则切换选项卡还会播放
	if(id == elcId) {// 当是电气ID时:加载电气图的操作
		// alert("电力图");
		$("#elcPicId").addClass("elc-BtnAct");
		$("#videoId").removeClass("elc-BtnAct");
		$("#elc_huanJingId").removeClass("elc-BtnAct");
		$("#elc_anFangId").removeClass("elc-BtnAct");
	} else if(id == videoId) {// 当是视频的id时:加载视频的操作
		console.log("视频");
		//$("#elc_video").html("<video class='dianqiPic' loop='loop' controls='controls'  preload='none' src='http://bpic.wotucdn.com/18/71/94/31bOOOPIC33.mp4'></video>");
		 $("#elc_video").html('<iframe  allowtransparency="true" frameborder="0" width="100%" height="100%" scrolling="no" src="../../video/video.html"></iframe>');
		$("#elc_video").css({
			"font-size": "43px",
			"text-align": "center",
			"line-height": "100px",
		});
		$("#fullScreen").css("display","none");// 当视频播放时全屏按钮隐藏
		
		$("#videoId").addClass("elc-BtnAct");
		$("#elcPicId").removeClass("elc-BtnAct");
		$("#elc_huanJingId").removeClass("elc-BtnAct");
		$("#elc_anFangId").removeClass("elc-BtnAct");
	}if (id == elc_huanJingId) {// 环境状态监测
		console.log("elc_huanJingId");
		$("#videoId").removeClass("elc-BtnAct");
		$("#elcPicId").removeClass("elc-BtnAct");
		$("#elc_huanJingId").addClass("elc-BtnAct");
		$("#elc_anFangId").removeClass("elc-BtnAct");
	}if (id == elc_anFangId) {// 安防监控
		console.log("elc_anFanId");
		$("#videoId").removeClass("elc-BtnAct");
		$("#elcPicId").removeClass("elc-BtnAct");
		$("#elc_huanJingId").removeClass("elc-BtnAct");
		$("#elc_anFangId").addClass("elc-BtnAct");
	}
}
// 电力图或 视频结束
var zhandianid;
function vueFunc(){
	var vm = new Vue({
		el:"#app",
		data:{
			msg:"威默电气",
			tabs:[],   // 电气图tabs
			urlStr:"", // 电气图地址
			tabId: 0,
			kehu:[],   // 站点
			zid:'',
			zhanDianID : "",  //站点id
			danweiID:'',//单位id
			danweiName:'',//上页选中来的单位名称
			unitName:'',//登录的单位名称
			zName:'',   //站点名称
		},
		mounted:function(){
			this.getSession();
		},
		methods:{
			getSession:function(){
				var vs = this;
				var userid,unitID,userType;
				var url="/bigscrenn/getUserSession";
			     $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
				    	 console.log("session数据："+data);
				    	 //js解析json串
			     	     var obj = JSON.parse(data);
			             if (obj.session.length>0){
			                   /*alert(obj.session[0].UserID);//用户id
			                   alert(obj.session[0].Name);//用户名称
			                   alert(obj.session[0].UnitID);//用户单位id
			                   alert(obj.session[0].UserAuthority);//用户权限 2 所有单位 3 本单位
			                   alert(obj.session[0].typeid);//系统分类id (比如对应前端八大类)
			                   alert(obj.session[0].zid);//当前用户的站点id*/			            	   
			            	   vs.userid = obj.session[0].UserID;
			 	  			   vs.unitID = obj.session[0].UnitID;
			 	  			   vs.userType = obj.session[0].UserAuthority;
			 	  			   //vs.zid = obj.session[0].zid;
			 	  			   
			 	  			   vs.danweiID = (obj.session[0].cid1).split(",")[0];  //单位id方法
			 	  			   vs.danweiName = (obj.session[0].cid1).split(",")[1];//上页选中来的单位名称
			 	  			   
			 	  			   			 	  			   
			 	  			   vs.zid = (obj.session[0].zid).split(",")[0];  //站点id
			 	  			   vs.zName = (obj.session[0].zid).split(",")[1];//上页选中来的站点名称
			 	  			   
			 	  			   //alert("我是三级站点id 和名称 ="+vs.zid + "名称" +vs.zName);
			 	  			   //console.log("站点id="+vs.zid);
			 	  			   $("#unitTitle span").text(vs.zName);
			            	 }
			                 console.log("userid="+vs.userid+"and unitID="+vs.unitID+"and userType="+vs.userType) ;
			                 zhandianid = vs.zid;
			                 onlineFunc();
			                 
			                 //alert("vs.danweiID = "+vs.danweiID);
			                 if(vs.danweiID==undefined||vs.danweiID==''){
			                	 vs.danweiID=vs.unitID;
			                 }
			                 //alert("vs.danweiID 2 = "+vs.danweiID);
			                if(vs.zid && vs.zid != '' && vs.zid != null && vs.zid!= undefined){
			                	vs.getUnitIData(vs.userid,vs.danweiID);
			                	vs.getPicData(vs.zid);
			                	vs.getPicData(vs.zid);
			                	
			                	wenduFun(vs.userid,vs.zid);//状态监测的表格方法
			                	
                 			    localStorage.setItem("stateMonitorCID", vs.zid);// 存储状态监测CID
                 			    localStorage.setItem("stateMonitorPicName",vs.zid);// 存储状态监测CID
			                }
			                //具体用户进来的操作
			                if(vs.userType==3){
			                	console.log("我的身份是具体用户");
			                	$(".backHome-box >a").css("display","none");// “返回首页”隐藏
			                }
				     }
			     });
			},
			getUnitIData:function(userid,unitid){
				var unitData = this;
				// userid用户id,unitid单位id,unitid为空时表示调用多个单位的站点信息
			    var url="/bigscrenn/getSiteList?userid="+userid+"&unitid="+unitid;
			    //alert("进来的站点地址="+url);
			    $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
				    	console.log("站点数据="+data);
                       // js解析json串
                       var obj = JSON.parse(data);
                       // alert(obj.total);//记录数
                       unitData.kehu = obj.rows;// 分类后的站点（用户）
                       
                       unitData.$nextTick(function() {
                    	   var arrr = $(".zhanDian");
                    	   // alert("arrr=="+arrr.length);
                    	   for (var n=0;n<arrr.length;n++){
                    		   arrr[n].index = n;
                    		   arrr[n].onclick = function(){
                    			    //alert($(this).text());
                    			   //alert("当前点击的站点="+obj.rows[this.index].CID);
                    			    $("#unitTitle span").text($(this).text());//标题
                    			   //unitData.getPicData(obj.rows[this.index].CID);
                    			   localStorage.setItem("stateMonitorCID", $(this).attr("cid"));// 存储状态监测CID
                    			   localStorage.setItem("stateMonitorPicName", $(this).attr("cid"));// 存储状态监测CID
                    			   window.location.href="specificUser.html";
                    			   
                    			   setSessionfunc('',obj.rows[this.index].CID+','+$(this).text(),'',(unitData.danweiID+','+unitData.danweiName));     // session存站点（第二个参）
                    			   
	                        	   selectSH();//关闭用户(站点)列表
                    		   }
                    		   
                    	   }
                       });
				     }
			     });
			},
			getPicData:function(CID){
				//alert("进来的电气图站点id="+CID);
				var d = this;
				// fid站点id
			    var url="/bigscrenn/getVlabelList?fid="+CID;     	 
			     $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
				    	 // alert("data===:"+data);
				    	 console.log(data);
                       // js解析json串
                       var obj = JSON.parse(data);
                       d.tabs = obj.rows;
                       var total = obj.total;
                       //alert("total=="+total);
                       if(total && total>0){
	                       d.$nextTick(function() {// 四个tabs渲染完成后的操作
	                    	   	d.urlStr = '/vlabel/actionshow?fid='+CID+'&id='+obj.rows[0].CID+'&bl=0.8&name='+obj.rows[0].VNAME;// 默认显示第一张图
	                    	   	var urlStrDp = '/vlabel/actionshow?fid='+CID+'&id='+obj.rows[0].CID+'&name='+obj.rows[0].VNAME;
	                    	   	//localStorage.setItem("urlStr", d.urlStr);            // 默认将第一张存储本地
	                    	   	localStorage.setItem("urlStr", urlStrDp);
	                    	   	localStorage.setItem("picName", obj.rows[0].VNAME);
								console.log("li === " + $("#tabDiv>button").length);
								$("#tabDiv>button").first().addClass("elc-BtnAct");  // 默认第一个大用户展开
								$("#tabDiv>button").click(function(){
									$(this).addClass("elc-BtnAct");                  // 点击当前添加类elc-BtnAct
									$(this).siblings().removeClass("elc-BtnAct");    // 点击当前的兄弟节点移除类elc-BtnAct
									var index = $("#tabDiv>button").index(this);
									// js解析json串
				                       var obj = JSON.parse(data);
				                       // alert(obj.total);//记录数
				                       for (var i=0;i<obj.rows.length;i++)
				                       {
				                             // alert(obj.rows[i].CID);//电气图id
				                             // alert(obj.rows[i].VNAME);//电气图名称
				                             if(index == i) {
												// alert(index);
												var str = '/vlabel/actionshow?fid='+CID+'&id='+obj.rows[i].CID+'&bl=0.8&name='+obj.rows[i].VNAME;
												var strDp = '/vlabel/actionshow?fid='+CID+'&id='+obj.rows[i].CID+'&name='+obj.rows[i].VNAME;
												console.log("str"+i+"==:"+str);
												d.urlStr = str;
												// 本地存储
												localStorage.setItem("urlStr", strDp);
												localStorage.setItem("picName", obj.rows[i].VNAME);
				                             }
				                             
				                       }
								})
							})
                       }if(total==0 || total == null){// total==0没有数据
				    		 console.log("没有数据");
				    		 d.urlStr = '';// 默认显示第一张图
                    	     localStorage.setItem("urlStr", '');// 默认将第一张存储本地
                    	     localStorage.setItem("picName",'');
				    	 }
				     }
			     });
			}
		}
	})
}

// 电气图全屏开始
function fullScreenBtn(urlStr){
	var urlStr = localStorage.getItem("urlStr");
	var picName = localStorage.getItem("picName");
	if(urlStr && picName){
		console.log("urlStr==:"+urlStr);
		// var url="/bigscrenn/getVlabelList?fid=000000000001";
		var index = layer.open({
		  type: 2,
		  title:picName,
		  content: urlStr,
		  area: ['320px', '195px'],
		  maxmin: false, // 开启最大化最小化按钮
		  skin: 'layui-layer-rim', //加上边框
		});
		layer.full(index);
		
		$(".layui-layer-rim p a").css({
				'color':'#fff',
				'display':'block',
				'fontSize':'14px',
				'lineHeight':'1.3rem'
			});
			$(".layui-layer-rim").css({
				'border':'none',
				'background':'#0055b3'
			});
		$(".layui-layer-rim a.layui-layer-ico").text('×').css({
			'color':'#fff',
			'fontSize':'2rem',
			'margin-top': '-15px',
			'background':'none'
		});
		
		$(".layui-layer-rim .layui-layer-title").css({'background':'#0055b3','color':'#fff',});
	}
	if(!urlStr){
		layer.msg('网络错误或加载数据失败');
	}
}
// 电气图全屏结束


//环境状态监测S
//三级的的实时负荷开始

function ssfhFunc(unitid,userid){
	//得到环境相关数据
	 var nameArr11=[];
	//unitid 站点id,userid用户id
	// var url="/bigtongji/getUnitIDHj?unitid=000000000001&userid=000000000001";
	 var url="/bigtongji/getUnitIDHj?unitid="+unitid+"&userid="+userid;     
	 //alert("环境  url = "+url);
	 $.ajax({
	      cache: true,
	      type: "POST",
	      url:url,
	      data:"",
	      async: true,       
	      success: function(data){
              //alert(data);
              var dataObj=eval("("+data+")");//转换为json对象 
              //alert(dataObj);
              //alert(dataObj);
            	var total= dataObj.total;
            	//alert(total);
               var map = new Array();//装数值
               var map2 = new Array();//
               var arr = new Array(); //装时间
               var con = new Array(); //装单位
               var name=[];
         	    for (var i = 0; i < dataObj.rows.length; i++) {
         		  //名字
         		var VNAME= dataObj.rows[i].VNAME;
         		nameArr11.push(VNAME);
         		//alert("----"+dataObj.rows[i].VNAME);
         		//值
         	    arr[i]=new Array(i); 
            	map[i]=new Array(i); 
            	con[i]=new Array(i); 
         		for (var j = 0; j < dataObj.rows[i].List.length; j++) {
            		map[i][j]=dataObj.rows[i].List[j].UNITNAME;
            		arr[i][j]=dataObj.rows[i].List[j].VALUE;
            		con[i][j]=dataObj.rows[i].List[j].CONVERSION;
               }
         	  }
         	//alert(name);alert(map); alert(arr);
         	//环境名
         	//alert(map[0]);
           //环境对应的值
       		/*alert(arr[0]);
       		alert(arr[1]);
       		alert(arr[2]);
       		alert(arr[3]);
       		alert(arr[4]);
       		alert(arr[5]);*/
         	   console.log(JSON.stringify(arr));
               console.log(JSON.stringify(map));
               hjjcTableFuncc(nameArr11,map,arr,con)
	         }
	 });
	 function hjjcTableFuncc(nameArr11,map,arr,con){
		 var fhrlDataArr = [];
			//alert(nameArr11.length);
			for(var i=0;i<nameArr11.length;i++){
				for(var j=0;j<map[i].length;j++){
					//alert(dateValueObj[0][j]);
					 fhrlDataArr.push({
						"name": nameArr11[i],
						"stateName": map[i][j],
						"value": arr[i][j],
						"danwei": con[i][j],
					}) 
				}
			}
			//alert("fhrlDataArr = "+JSON.stringify(fhrlDataArr))
			  $('#hjjc').bootstrapTable({
					data:fhrlDataArr,
					data1: [{
					"name":"一号",
					"stateName": "2018-11-16",
					"value": 123,
					"danwei": 332,
					}, {
						"name":"二号",
						"stateName": "2018-11-16",
						"value": 123,
						"danwei": 332,
					}, {
						"name":"三号",
						"stateName": "2018-11-16",
						"value": 123,
						"danwei": 332,
					}, {
						"name":"四号",
						"stateName": "2018-11-16",
						"value": 123,
						"danwei": 332,
					}, {
						"name":"五号",
						"stateName": "2018-11-16",
						"value": 123,
						"danwei": 332,
					}, {
						"name":"六号",
						"stateName": "2018-11-16",
						"value": 123,
						"danwei": 332,
					},
				
				],
				//columns: columnsObj,
				columns: [{
						field: 'name',
						title: '站点名称',
						
					},{
						field: 'stateName',
						title: '环境名称',
					},
					{
						field: 'value',
						title: '状态值',
					},
					{
						field: 'danwei',
						title: '单位',
					}

				]
			}); 
	 }
	
} 
//环境状态监测E










//返回上一级跳转逻辑处理
function bachFunc(){
	var urlsStr = localStorage.getItem("urls");
	var ss = JSON.parse(urlsStr);
    console.log(ss.yiji);
    if(ss.sanji != undefined && ss.sanji !=''){
    	//alert(ss.sanji);
	    location.href = './specificHome.html';
    	return;
    }if(ss.erji != undefined && ss.erji !=''){
    	//alert(ss.erji);
        location.href = './intlgMonitor.html';
        return;
    }if(ss.yiji != undefined && ss.yiji !=''){
    	//alert(ss.yiji);
	    location.href = './pro_Home.html';
		return;
    }else{
	    //alert(222)
    }
}

//得到温度
//wenduFun();
function wenduFun(userid,zid){
//参数userid用户id,unitid站点id
//var url="/bigscrenn/getZwd?userid=0100000000000004&unitid=000000000001";
var url="/bigscrenn/getZwd?userid="+userid+"&unitid="+zid;
//alert("得到温度 url= "+url); 
$.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
           //alert("温度 = "+data);
           //$("#wendu").text(data+"°C");
	    	 var moreArr = data.split(',');
	    	 if($("#wenduUL >div").length>0){
	    		 $("#wenduUL").empty();
	    	 }
	    	 //$("#wenduUL").append('<li><span><img src="./images/wendu/wendu.png"/>&nbsp;'+moreArr[0]+'</span><span><img src="./images/wendu/shidu.png"/>&nbsp;'+moreArr[1]+'</span></li><li><span><img src="./images/wendu/shui.png"/>&nbsp;'+moreArr[2]+'</span><span><img src="./images/wendu/yanwubaojing.png"/>&nbsp;'+moreArr[3]+'</span></li><li><span><img src="./images/wendu/chouyang.png"/>&nbsp;'+moreArr[4]+'</span><span><img src="./images/wendu/shengwu.png"/>&nbsp;'+moreArr[5]+'</span></li>')
	    	 
	    	 //$("#wenduText").text(moreArr[6]);
	    	 
	    	 //new add 20190520 S
	    	 var newArr1 = [],newArr2=[];
	    	 for(var i=0;i<moreArr.length;i++){
	    		 var splitArr = moreArr[i].split(":");
	    		 newArr1.push(splitArr[0]+":"+splitArr[1]);
	    		 if(splitArr[2]== undefined){
	    			 splitArr[2]=''
	    		 }
	    		 newArr2.push(splitArr[2]);
	    		 
	    	 }
	    	 var str11 = '<div class="am-u-lg-6">'
								+'	<span class="hjSpan" id='+newArr2[0]+' style="cursor: pointer;"><img src="./images/wendu/wendu.png">&nbsp;<i>'+newArr1[0]+'</i></span>'
								+'</div>'
								+'<div class="am-u-lg-6">'
								+'	<span class="hjSpan" id='+newArr2[1]+' style="cursor: pointer;"><img src="./images/wendu/shidu.png">&nbsp;<i>'+newArr1[1]+'</i></span>'
								+'</div>'
								+'<div class="am-u-lg-6">'
								+'	<span class="hjSpan" id='+newArr2[2]+' style="cursor: pointer;"><img src="./images/wendu/shui.png">&nbsp;<i>'+newArr1[2]+'</i></span>'
								+'</div>'
								+'<div class="am-u-lg-6">'
								+'	<span class="hjSpan" id='+newArr2[3]+' style="cursor: pointer;"><img src="./images/wendu/yanwubaojing.png">&nbsp;<i>'+newArr1[3]+'</i></span>'
								+'</div>'
								+'<div class="am-u-lg-6">'
								+'	<span class="hjSpan" id='+newArr2[4]+' style="cursor: pointer;"><img src="./images/wendu/chouyang.png">&nbsp;<i>'+newArr1[4]+'</i></span>'
								+'</div>'
								+'<div class="am-u-lg-6">'
								+'	<span class="hjSpan" id='+newArr2[5]+' style="cursor: pointer;"><img src="./images/wendu/shengwu.png">&nbsp;<i>'+newArr1[5]+'</i></span>'
								+'</div>'
								+'<div class="am-u-lg-6">'
								+'	<span class="hjSpan" id='+newArr2[6]+' style="cursor: pointer;"><img src="./images/wendu/men.png"><i>'+newArr1[6]+'</i></span>'
								+'</div>'
								+'<div class="am-u-lg-6">'

								+'</div>';
	    	// alert("--newArr1---"+newArr1+"--newArr2--"+newArr2);
	    	 //$("#wenduUL").append('<li class="safe-li"><span><span>&nbsp;安全运行:</span><i id="safeDay"></i><span>天</span></span><span class="hjSpan" id="'+newArr2[0]+'" ><img src="./images/wendu/wendu.png"/>&nbsp;<i id="">'+newArr1[0]+'</i></span></li><li><span class="hjSpan" id='+newArr2[1]+'><img src="./images/wendu/shidu.png"/>&nbsp;<i>'+newArr1[1]+'</i></span><span class="hjSpan" id='+newArr2[2]+'><img src="./images/wendu/shui.png"/>&nbsp;<i>'+newArr1[2]+'</i></span></li><li><span class="hjSpan" id='+newArr2[3]+'><img src="./images/wendu/yanwubaojing.png"/>&nbsp;<i>'+newArr1[3]+'</i></span><span class="hjSpan" id='+newArr2[4]+'><img src="./images/wendu/chouyang.png"/>&nbsp;<i>'+newArr1[4]+'</i></span></li><li><span class="hjSpan" id='+newArr2[5]+'><img src="./images/wendu/shengwu.png"/>&nbsp;<i>'+newArr1[5]+'</i></span><span class="hjSpan" id='+newArr2[6]+'><img src="./images/wendu/men.png"/>&nbsp;<i>'+newArr1[6]+'</i></span></li>')
	    	 //$("#wenduUL").append('<li><span class="hjSpan" id="'+newArr2[0]+'"><img src="./images/wendu/wendu.png"/>&nbsp;<i>'+newArr1[0]+'</i></span><span class="hjSpan" id="'+newArr2[1]+'"><img src="./images/wendu/shidu.png"/>&nbsp;<i>'+newArr1[1]+'</i></span></li><li><span class="hjSpan" id="'+newArr2[2]+'"><img src="./images/wendu/shui.png"/>&nbsp;<i>'+newArr1[2]+'</i></span><span class="hjSpan" id="'+newArr2[3]+'"><img src="./images/wendu/yanwubaojing.png"/>&nbsp;<i>'+newArr1[3]+'</i></span></li><li><span class="hjSpan" id="'+newArr2[4]+'"><img src="./images/wendu/chouyang.png"/>&nbsp;<i>'+newArr1[4]+'</i></span><span class="hjSpan" id="'+newArr2[5]+'"><img src="./images/wendu/shengwu.png"/>&nbsp;<i>'+newArr1[5]+'</i></span></li><li  style="text-align:left;"><span class="hjSpan" id="'+newArr2[0]+'"><img src="./images/wendu/men.png"/><i>'+newArr1[6]+'</i></span></li>');
			$("#wenduUL").append(str11);				
	    	 $("#wenduText").text(newArr1[6]);
	    	 
	    	//判断环境值操作
	    	 panduHuanjingVfunc();
	    	 function panduHuanjingVfunc(){
	    		 var hjSpan = $("#wenduUL div span.hjSpan");
	    		 for(var i=0;i<hjSpan.length;i++){
	    			 //var hjVStr = $("#wenduUL li span").eq(i).text("湿度:100°");
	    			 var hjVStr = $("#wenduUL div span.hjSpan >i").eq(i).text();
	    			 var huanjingText = hjVStr.split(':')[0];
	    			 var huanjingV = hjVStr.split(':')[1];
	    			 var valueStr = huanjingV.substring(0,3);
		    		 //alert("hjVStr = "+hjVStr);
		    		 if(valueStr.indexOf("℃")){
		    			 valueStr =  valueStr.replace("℃","");  //去除字符算中的℃
		    		 }
		    		 if(valueStr.indexOf("°")){
		    			 valueStr =  valueStr.replace("°","");  //去除字符算中的°
		    		 }
		    		 if(valueStr.indexOf("%")){
		    			 valueStr =  valueStr.replace("%","");  //去除字符算中的%
		    		 }
		    		 
		    		 //温度
		    		 if(huanjingText.indexOf("温度") >= 0 && parseInt(valueStr) >40) {
		    			 //alert(parseInt(valueStr)+'----');
		    			 replaceImg(i,'wendur');
	    			 }
		    		 
		    		 //湿度
		    		 if(huanjingText.indexOf("湿度") >= 0 && parseInt(valueStr) > 100) { 
		    			 //alert(parseInt(valueStr)+'--2--');
		    			 replaceImg(i,'shidur');
	    			 }
		    		 //水浸
		    		 if(huanjingText.indexOf("水浸") >= 0 && huanjingV =="1") { 
	    				 replaceImg(i,'shuir');
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('水浸:有');
	    			 }if(huanjingText.indexOf("水浸") >= 0 && huanjingV =="0") { 
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('水浸:正常');
	    			 }
	    			 //烟感
	    			 if(huanjingText.indexOf("烟感") >= 0 && huanjingV =="1") { 
	    				 replaceImg(i,'yanwubaojingr');
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('烟感:有');
	    			 }
	    			 if(huanjingText.indexOf("烟感") >= 0 && huanjingV =="0") { 
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('烟感:正常');
	    			 }
	    			 //臭氧
	    			 if(huanjingText.indexOf("臭氧") >= 0 && huanjingV =="1") { 
	    				 replaceImg(i,'chouyangr');
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('臭氧:异常');
	    			 }
	    			 if(huanjingText.indexOf("臭氧") >= 0 && huanjingV =="0") { 
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('臭氧:正常');
	    			 }
	    			 //生物探测
	    			 if(huanjingText.indexOf("生物探测") >= 0 && huanjingV =="1") { 
	    				 replaceImg(i,'shengwur') ;
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('生物探测:有');
	    			 }
	    			 if(huanjingText.indexOf("生物探测") >= 0 && huanjingV =="0") { 
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('生物探测:正常');
	    			 }
	    			 //门状态
	    			 if(huanjingText.indexOf("门状态") >= 0 && huanjingV =="1") { 
	    				 replaceImg(i,'menr');
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('门状态:开');
	    			 }
	    			 if(huanjingText.indexOf("门状态") >= 0 && huanjingV =="0") { 
	    				 $("#wenduUL div span.hjSpan").eq(i).find('i').text('门状态:关');
	    			 }
	    			 
	    		 }
	    		 
	    		 
	    	 }
	    	 function replaceImg(i,imgName){
	    		 //alert("imgName = "+imgName);
	    		 return $("#wenduUL div span.hjSpan").eq(i).find('img').attr('src','./images/wendu/'+imgName+".png")
	    	 }
    		 
	    	 $("#wenduUL div span.hjSpan").css('cursor','pointer');
	    	 
	    	 //环境点击事件操作
	    	 $('#wenduOutID span.hjSpan').on('click',function(){
	    		 var index = $(this).text();
	    		 wenduTKTitle = index;
	    		 wenduTKDataid =  $(this).attr('id');
	    		 
    			 //alert("wenduTKDataid = "+wenduTKDataid);
    			 if(wenduTKDataid != ''){
        			 wenduTKunc(); 
    			 }
    			 
	    	 });
	    	 
	    	 function wenduTKunc(){
	    		 //得到环境项的实时曲线分析图表
	    		   var wenduValueArr = [],wenduXArr=[];
	    		   var wenduDanwei = '';
	    		   test();
	    		   function test(){
	    		       //参数id统计项id
	    		       //var url="/bigscrenn/getHActualStatistics?id=A00000000106";
	    		       var url="/bigscrenn/getHActualStatistics?id="+wenduTKDataid;
	    		       //alert("得到环境项的实时曲线分析图表 url = "+url);
	    		        $.ajax({
	    		   	     cache: true,
	    		   	     type: "POST",
	    		   	     url:url,
	    		   	     data:"",
	    		   	     async: false,				   
	    		   	     success: function(data){
	    	                  //alert(data);
	    	                  //js解析json串
	    		   	    	 console.log(data,"环境弹框data");
	    	                  var obj = JSON.parse(data); 
	    	                  
	    	                  for (var i=0;i<obj.rows.length;i++){
	    	                        //alert(obj.rows[i].ITEMNAME);//项目
	    	                        //alert(obj.rows[i].VALUEA);//值
	    	                        //alert(obj.rows[i].CONVERSION);//单位
	    	                        //alert(obj.rows[i].CDATE);//日期
	    	                	  wenduValueArr.push(obj.rows[i].VALUEA);
	    	                	  wenduXArr.push((obj.rows[i].CDATE).split(' ')[1]);
	    	                  }
	    	                  wenduDanwei = obj.rows[0].CONVERSION
	    		              //alert(wenduValueArr)               
	    		              setTimeout(wenduTKEchartFunc,345);                
	    		   	     }
	    		        });
	    		        
	    		   }

	    		   
	    		   
	    		   
	    		   layer.open({
	    			  type: 1,
	    			  //title:"负荷容量",
	    			  title:wenduTKTitle,
	    			  scrollbar:false,
	    			  skin: 'layui-layer-rim', //加上边框
	    			  area: ['800px', '500px'], //宽高
	    			  content: '<div class="wendu-tk-box" id="fhrlTkbox"></div>'
	    			});
	    		   $(".layui-layer-rim p a").css({
  						'color':'#fff',
  						'display':'block',
  						'fontSize':'14px',
  						'lineHeight':'1.3rem'
  					});
   					$(".layui-layer-rim").css({
  						'border':'none',
  						'background':'#07256b'
  					});
					$(".layui-layer-rim a.layui-layer-ico").text('×').css({
						'color':'#fff',
						'fontSize':'2rem',
						'margin-top': '-15px',
						'background':'none'
					});
					
					$(".layui-layer-rim .layui-layer-title").css({'background':'#07256b','color':'#fff',});
	    		   
	    		   function wenduTKEchartFunc(){
	    			   var childChart1 = echarts.init(document.getElementById('fhrlTkbox'));
	    				var option1 = {
	    						title: {
	    							text: '单位（'+wenduDanwei+'）',
	    							x: '5%',
	    							y:'8%',
	    							textStyle: {
	    								// 文字颜色
	    								color: '#fff',
	    								// 字体风格,'normal','italic','oblique'
	    								fontStyle: 'normal',
	    								// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
	    								// 400...
	    								fontWeight: '100',
	    								// 字体系列
	    								fontFamily: 'sans-serif',
	    								// 字体大小
	    							    fontSize: '120%'
	    							}
	    						},
	    					backgroundColor: "#07256b",
	    					tooltip: {
	    						trigger: 'axis',
	    						show:true,
	    						axisPointer: {
	    							lineStyle: {
	    								color: '#57617B'
	    							}
	    						}
	    					},
	    					legend: {
	    						orient: 'horizontal',// 'vertical'
	    						icon: 'rect',
	    						//data:legenArr[0],
	    						data: ['A相电流', 'B相电流', 'C相电流'],
	    						align: 'right',
	    						right: '2%',
	    						top: '5%',
	    						textStyle: {
	    							color: "#fff"
	    						},
	    						itemWidth: 30,
	    						itemHeight: 10,
	    						itemGap: 15
	    					},
	    					grid: {
	    						left: '5%',
	    						right: '3%',
	    						top: '20%',
	    						bottom: '5%',
	    						containLabel: true
	    					},
	    					xAxis: [{
	    						type: 'category',
	    						boundaryGap: false,
	    						axisLine: {
	    							lineStyle: {
	    								color: '#fff'
	    							}
	    						},
	    						axisLabel: {
	    							interval: 1, 
	    							//formatter: '{value}<br/>点',
	    							formatter: '{value}',
	    							 rotate:40,
	    							show: true,
	    							splitNumber: 3,
	    							textStyle: {
	    								fontFamily: "微软雅黑",
	    								color: "rgba(255,255,255,.6)",
	    								fontSize: '80%',
	    							},
	    						},
	    						data:wenduXArr,
	    						//data: ['13:00', '13:05', '13:10', '13:15', '13:20', '13:25', '13:30', '13:35', '13:40', '13:45', '13:50', '13:55']
	    					}, {
	    						axisLine: {
	    							show: false, //上横轴
	    							lineStyle: {
	    								color: 'red',
	    							}
	    						},

	    					}],
	    					yAxis: [{
	    						axisLabel: {
	    							show: true,
	    							formatter: '{value}'
	    						},
	    						splitLine: {
	    							lineStyle: {
	    								color: 'rgba(255,255,255,.1)'
	    							}
	    						},
	    						axisLine: {
	    							lineStyle: {
	    								color: '#fff'
	    							}
	    						},
	    					}],
	    					series:[],
	    					
	    				};
	    				
	    				option1.series = [{
	    						//name: legenArr[0],
	    						//name: 'A相电流',
	    						type: 'line',
	    						smooth: true,
	    						symbol: 'circle',
	    						symbolSize: 5,
	    						showSymbol: false,
	    						lineStyle: {
	    							normal: {
	    								width: 3
	    							}
	    						},
	    						
	    						itemStyle: {
	    							//normal: borderColor[0],
	    							normal: {
	    								color: '#f4a240',
	    								borderColor: '#f4a240',
	    								borderWidth: 12
	    							}
	    						},
	    						//data: [, , , 34, 110, 220, 150, 75, 30, , , ]
	    						data: wenduValueArr
	    					}];
	    				childChart1.setOption(option1,true);
	    		   }
	    	   }
	    	 //new add 20190520 E
	     }
 });
 
}

//温度结束

//值班人员
//onlineFunc();
function onlineFunc(){
	//alert("zhandianid 3= "+zhandianid);
	// unitid 是站点ID
	// var url="/bigtongji/getRotaList?unitid=000000000001";
	var url="/bigtongji/getRotaList?unitid="+zhandianid;
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
            // alert(data);
            console.log(data);
            var dataObj=eval("("+data+")");// 转换为json对象
            // alert(dataObj);
            // alert(dataObj);
            if(dataObj.rows.length>0){
        		 $("#onlineNotice").html('');
        		 for (var i = 0; i < dataObj.rows.length; i++) {
             		var cid= dataObj.rows[i].cid;
             		var name= dataObj.rows[i].rname;
             		var phone= dataObj.rows[i].phoneCode;
             		//alert(cid);
             		//alert("cid="+cid+"name="+name+"phone="+phone);
            		 $("#onlineNotice").append('<li><span>👨‍⚖️&nbsp;&nbsp;<span id="onlineName1">'+name+'</span>&nbsp;电话：</span><span>'+phone+'</span></li>');
             	  }
        	  }
        	 if(dataObj.rows.length==0){
        		$("#onlineNotice").html(''); 
        	 }
	     }
	 });

}
//值班人员结束

//人脸识别 开始
/* 
 * 人脸相关信息列表
 *unitid 站点ID
 * 
 */
setTimeout(FaceRecoFunc,345);
function FaceRecoFunc(){
	 //alert("zhandianid 3= "+zhandianid);
	 var arr1 = [],arr2=[];
	 var url="/bigtongji/getRlUser?unitid="+zhandianid;   
	 $.ajax({
	      cache: true,
	      type: "POST",
	      url:url,
	      data:"",
	      async: false,       
	      success: function(data){
	          //alert(data);
	          console.log(data,'人脸识别');
	          var dataObj=eval("("+data+")");//转换为json对象 
	          //alert(dataObj);
	          //alert(dataObj);
	          console.log(JSON.stringify(dataObj));
	          //开门历史记录
	          console.log("dataObj . records = "+JSON.stringify(dataObj.records));
	          for (var i = 0; i < dataObj.records.length; i++) {
	        	  //开门人员姓名
	               var name= dataObj.records[i].name;
	               //开门时间
	               var openTime= dataObj.records[i].openTime;
	               //开门人员电话
	               var phone= dataObj.records[i].phone;
	               //开门类型 //开门类型 1:app 2:刷卡 3:密码 4:视频 5:物控 6:电话 7:室内机 8:人脸识别
	               var openType= dataObj.records[i].openType;
	               //站点ID
	               var unitid= dataObj.records[i].unitid;
	               //alert(name);
	               
	               if(openType == '1' ){
	            	   openType = 'app'
	               }
	               if(openType == '2' ){
	            	   openType = '刷卡'
	               }
	               if(openType == '3' ){
	            	   openType = '密码'
	               }
	               if(openType == '4' ){
	            	   openType = '视频'
	               }
	               if(openType == '5' ){
	            	   openType = '物控'
	               }
	               if(openType == '6' ){
	            	   openType = '电话'
	               }
	               if(openType == '7' ){
	            	   openType = '室内机'
	               }
	               if(openType == 8 ){
	            	   openType = '人脸识别'
	               }
	               
	               arr1.push({
	            	     "name":name,
            			 "openTime":openTime,
            			 "phone":phone,
            			 "openType":openType,
            	   });
                } 
	          //人员信息
	          console.log("dataObj . rlUser = "+JSON.stringify(dataObj.rlUser));
	          for (var i = 0; i < dataObj.rlUser.length; i++) {
	        	   //授权状态 是否有权限 0:未授权 1:授权
	              var authState= dataObj.rlUser[i].authState;
	              //用户手机
	              var phone= dataObj.rlUser[i].phone;
	              //用户姓名
	              var name= dataObj.rlUser[i].name;
	              //站点ID
	              var unitid= dataObj.rlUser[i].unitid;
	              //alert(name);
	              
	              if(authState == '0' ){
	            	  authState = '未授权'
	               }
	               if(authState == '1' ){
	            	   authState = '授权'
	               }
	              arr2.push({
	            	 "name":name,
         			 "phone":phone,
         			 "authState":authState,
         			 
         	      });
	          } 
	      }
	 });
	 
	 //表1
     $('#faceRec1').bootstrapTable({
    	    data:arr2,
    		//列数
    		columns: [{
    				field: 'name',
    				title: '名字',
    				width: '33%'
    			},
    			{
    				field: 'phone',
    				title: '手机号',
    			},
    			{
    				field: 'authState',
    				title: '授权状态',
    				width: '33%'
    			},
    			
    		]
    });
   //表2
     $('#faceRec2').bootstrapTable({
    	    data:arr1,
    		//列数
    		columns: [{
    				field: 'name',
    				title: '名字',
    				width: '20%'
    			},
    			{
    				field: 'phone',
    				title: '手机号',
    				width: '30%'
    			},
    			{
    				field: 'openTime',
    				title: '开门时间',
    				width: '30%'
    			},
    			
    			{
    				field: 'openType',
    				title: '开门类型',
    				width: '20%'
    			},
    		]
    });
}
//人脸识别 结束
